package com.stars.empoly.vmodel

import android.app.Application
import android.text.TextUtils
import androidx.databinding.Bindable
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.stars.empoly.BR
import com.stars.empoly.model.DriverProfitTop
import com.stars.empoly.utils.net.NetEngine
import com.trailer.base.base.BRRepository
import com.trailer.base.base.BRViewModel
import com.trailer.base.net.IResp
import kotlinx.coroutines.launch

class IncomeVModel(application: Application) :  BRViewModel<BRRepository>(application)  {

   // var image: MutableLiveData<String> = MutableLiveData("")


    val bean = MutableLiveData<DriverProfitTop>()

    fun getHeadInfo(){
        viewModelScope.launch {
            var it=repository().lreq { NetEngine.service.driverProfitTop() }
            if(it.ok()){
                bean.value=it.data
            }
        }
    }

    fun setChoseType(type:String?):String{
        if(!TextUtils.isEmpty(type)&&type.equals("1")){
            return "平台"

        }else{
            return "轿车"
        }
    }



    @Bindable
    var k: String? =null
        set(value) {
            field = value
            notifyPropertyChanged(BR.k)
        }
    override fun apiFunc(): suspend () -> IResp<*> {
        return  {NetEngine.service.Query(k, "10", repository().page)}

    }


}



